package controller;

import java.io.Serializable;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import paypal.PaypalService;

import util.MessageNotificationHepler;
import dao.ThamsochungDAO;

@ManagedBean(name = "adminHomeBean")
@ViewScoped
public class AdminHomeBean implements Serializable {

	private static final long serialVersionUID = 1L;

	private int soSanPhamTrenMotTrang;

	@PostConstruct
	public void init() {
		setSoSanPhamTrenMotTrang((int) (new ThamsochungDAO())
				.LayGiaTriCuaThamSo(ThamsochungDAO.TenThamSo.SO_SAN_PHAM_TREN_TRANG));
	}

	public void SuaGiaTriThamSo() {
		System.out
				.println("Sửa giá trị tham số: " + getSoSanPhamTrenMotTrang());
		(new ThamsochungDAO()).SetGiaTriCuaThamSo(
				ThamsochungDAO.TenThamSo.SO_SAN_PHAM_TREN_TRANG,
				getSoSanPhamTrenMotTrang());
		
		MessageNotificationHepler
				.ShowMessage("Sửa giá trị tham số thành công!");
	}

	// ------------------
	public int getSoSanPhamTrenMotTrang() {
		return soSanPhamTrenMotTrang;
	}

	public void setSoSanPhamTrenMotTrang(int soSanPhamTrenMotTrang) {
		this.soSanPhamTrenMotTrang = soSanPhamTrenMotTrang;
	}

}
